import { reactive } from "vue"
import { defineStore } from "pinia"
import { getStorageUser, setStorageUser } from "/utils/app-utils"

export const userInfo = defineStore("userInfo", () => {
  const state = reactive({
    // 用户信息持久化存储
    info: getStorageUser()
  })

  // 调用此方法更新用户存储信息
  function setInfo(e) {
    state.info = e
    setStorageUser(e)
  }

  return {
    state,
    setInfo
  }
})
